﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using RED_NET_Core.Helper;
namespace RED_NET_Core.Entity
{
    public class UsersRel
    {
        #region [Properties Of Photo]
        private int _id;
        private int _uId;
        private int _attentionId;
        private DateTime _addTime;
        #endregion

        #region [Properties Of Photo]
        public int Id 
        {
            get { return _id; }
            set { _id = value; } 
        }
        public int UId
        {
            get { return _uId; }
            set { _uId = value; }
        }
        public int AttentionId 
        {
            get {return  _attentionId; }
            set { _attentionId = value; }
        }
        public DateTime AddTime
        {
            get {return  _addTime; }
            set { _addTime = value; }
        }
        #endregion
        #region [AddItem]
        /// <summary>
        /// 在数据库中添加一条记录
        /// </summary>
        /// <returns></returns>
        public int AddItem()
        {
            int _id = -1;
            SqlParameter[] _param = new SqlParameter[3];
            _param[0] = new SqlParameter("@UId", _uId.ToString());
            _param[1] = new SqlParameter("@AttentionId", _attentionId.ToString());
            _param[2] = new SqlParameter("@AddTime", _addTime.ToString());

            string _smdStr = "insert into _UserRel(_UId,_AttentionId,_AddTime) values(@UId,@AttentionId,@AddTime) SELECT   SCOPE_IDENTITY()   as   '_Id'";
            OwnSqlHelper _shp = new OwnSqlHelper();
            try
            {
                _id = Int32.Parse(_shp.ExecuteScalar(_smdStr, _param));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return _id;
        }
        #endregion
    }
}
